﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using Validity.Rules;
using Validity.Rules.Decorators;

namespace Validity.Test.Rules.Decorators
{
  [TestClass]
  public class ComparisonRuleDecoratorTest
  {
    [TestMethod]
    public void TestIsViolatedByDelegated()
    {
      Comparison<IComparable> comparer = (lhs, rhs) => String.Compare((String)lhs, (String)rhs, StringComparison.OrdinalIgnoreCase);
      var baseRuleMock = new Mock<IComparisonRule<ObjectStub, IComparable>>(MockBehavior.Strict);
      var rule = new ComparisonRuleDecorator<ObjectStub, IComparable>(baseRuleMock.Object);
      var obj = new ObjectStub();

      baseRuleMock.Setup(mock => mock.IsViolatedBy(obj, "string", comparer)).Returns(false);

      Assert.IsFalse(rule.IsViolatedBy(obj, "string", comparer));
    }
  }
}
